﻿module Enferno.Public.Web.Components.Models {
    
    export class ParametricModel {
        constructor(serverObject?: any) {
            this.values = new Array<ParametricValueModel>();

            if (serverObject != null) {
                this.id = serverObject.id;
                this.name = serverObject.name;
                this.description = serverObject.description;
                this.unitOfMeasurement = serverObject.unitOfMeasurement;
                this.isPrimary = serverObject.isPrimary;
                this.groupId = serverObject.groupId;
                this.group = serverObject.group;

                Enumerable.from(serverObject.values).forEach(value => this.values.push(new ParametricValueModel(value)));
            }
        }

        public toString(): string {
            return this.id.toString();
        }

        public id: number;
        public name: string;
        public description: string;
        public unitOfMeasurement: string;
        public isPrimary: boolean;
        public groupId: number;
        public group: string;
        public values: Array<ParametricValueModel>;
    }

} 